home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / Borland / Borland C++ V5.02 / BLAZER.PAK / BLAZER.H < prev    next >
C/C++ Source or Header  |  1997-05-06  |  8KB  |  334 lines

  1. //----------------------------------------------------------------------------
  2. // ObjectWindows
  3. // (c) Copyright 1996, 1996 by Borland International, All Rights Reserved
  4. //
  5. // Declares the classes used in this example application:
  6. //  TBlazerApp
  7. //  TClientWindow      Has context sensitive help
  8. //  TSpeedBallWindow   Has context menu
  9. //  TAboutWindow       Has context sensitive help
  10. //----------------------------------------------------------------------------
  11. #if !defined(BLAZER_H)
  12. #define BLAZER_H
  13.  
  14. #if !defined(OWL_APPLICAT_H)
  15. # include <owl/applicat.h>
  16. #endif
  17. #if !defined(OWL_HLPMANAG_H)
  18. # include <owl/hlpmanag.h>
  19. #endif
  20. #if !defined(OWL_RCNTFILE_H)
  21. # include <owl/rcntfile.h>
  22. #endif
  23. #if !defined(OWL_PANESPLI_H)
  24. # include <owl/panespli.h>
  25. #endif
  26. #if !defined(OWL_LISTWIND_H)
  27. # include <owl/listwind.h>
  28. #endif
  29. #if !defined(OWL_TREEWIND_H)
  30. # include <owl/treewind.h>
  31. #endif
  32. #if !defined(OWL_LAYOUTWI_H)
  33. # include <owl/layoutwi.h>
  34. #endif
  35. #if !defined(OWL_DIBITMAP_H)
  36. # include <owl/dibitmap.h>
  37. #endif
  38. #if !defined(OWL_SPLASHWI_H)
  39. # include <owl/splashwi.h>
  40. #endif
  41. #if !defined(OWL_COMBOBOX_H)
  42. # include <owl/combobox.h>
  43. #endif
  44. #include <cstring.h>
  45.  
  46. #include "blazer.rh"
  47. #include "helpids.hh"
  48.  
  49. #if defined(BI_NAMESPACE)
  50. namespace OWL {
  51. #endif
  52.  
  53. class _OWLCLASS TMailer;
  54. class _OWLCLASS TCelArray;
  55. class _OWLCLASS TImageList;
  56. class _OWLCLASS TStatusBar;
  57. class _OWLCLASS THarbor;
  58. class _OWLCLASS TWinGIdentity;
  59. class _OWLCLASS TButton;
  60. class _OWLCLASS TMciWaveAudio;
  61.  
  62. #if defined(BI_NAMESPACE)
  63. } // namespace OWL
  64. #endif
  65.  
  66. //
  67. // Constants
  68. //
  69. const int TestImage  = 100;
  70. const int TreeWindId = 101;
  71. const int ListWindId = 102;
  72. const int DrivesId   = 103;
  73.  
  74. //
  75. // class TBlazerApp
  76. // ~~~~~ ~~~~~~~~~~
  77. // The main application class.
  78. // Mixes in THelpFileManager for context sensitive help
  79. // and TRecentFiles for managing a most-recently-used file list.
  80. //
  81. class TBlazerApp : public TApplication, public THelpFileManager, public TRecentFiles {
  82.   public:
  83.     TBlazerApp();
  84.    ~TBlazerApp();
  85.  
  86.     // Override virtual functions
  87.     //
  88.     void InitMainWindow();
  89.     void InitInstance();
  90.     TMailer* GetMailer();
  91.  
  92.   private:
  93.     void    CmFileSelect();
  94.     void    CmHelpAbout();
  95.     TResult CmMruSelected(TParam1 wp, TParam2);
  96.  
  97.     TMailer*       Mailer;
  98.     THarbor*       Harbor;
  99.  
  100.   DECLARE_RESPONSE_TABLE(TBlazerApp);
  101. };
  102.  
  103.  
  104. //
  105. // class TPaneTreeWindow
  106. // ~~~~~ ~~~~~~~~~~~~~~~
  107. class TPaneTreeWindow : public TTreeWindow {
  108.   public:
  109.     TPaneTreeWindow(TWindow* parent, int id, int x, int y, int w, int h,
  110.                     TStyle style = twsNone, TModule* module = 0)
  111.     :
  112.       TTreeWindow(parent, id, x, y, w, h, style, module)
  113.     {
  114.     }
  115.  
  116.     bool CanClose2(TReasonToClose)
  117.     {
  118.       return false;
  119.     }
  120.  
  121. };
  122.  
  123.  
  124. //
  125. // class TPaneListWindow
  126. // ~~~~~ ~~~~~~~~~~~~~~~
  127. class TPaneListWindow : public TListWindow {
  128.   public:
  129.     TPaneListWindow(TWindow* parent, int id, int x, int y, int w, int h,
  130.       TModule* module = 0)
  131.     :
  132.       TListWindow(parent, id, x, y, w, h, module)
  133.     {
  134.     }
  135.  
  136.     bool CanClose2(TReasonToClose)
  137.     {
  138.       return false;
  139.     }
  140. };
  141.  
  142.  
  143. //
  144. // class TComboBoxAsGadget
  145. // ~~~~~ ~~~~~~~~~~~~~~~~~
  146. class TComboBoxAsGadget : public TComboBox {
  147.   public:
  148.     TComboBoxAsGadget(TWindow*        parent,
  149.                       int             id,
  150.                       int x, int y, int w, int h,
  151.                       uint32          style,
  152.                       uint            textLimit,
  153.                       TModule*        module = 0)
  154.     :
  155.       TComboBox(parent, id, x, y, w, h, style, textLimit, module)
  156.     {
  157.     }
  158.  
  159.   private:
  160.     void CbnSelChanged();
  161.  
  162.   DECLARE_RESPONSE_TABLE(TComboBoxAsGadget);
  163. };
  164.  
  165.  
  166.  
  167. //
  168. // class TClientWindow
  169. // ~~~~~ ~~~~~~~~~~~~~
  170. // The main SDI window.
  171. // Has context sensitive help.
  172. //
  173. class TClientWindow : public TPaneSplitter {
  174.   public:
  175.     enum FileType {
  176.       Directory, OpenDirectory
  177.     };
  178.     TClientWindow(TWindow* parent = 0);
  179.    ~TClientWindow();
  180.  
  181.     void CbnDriveSelected();
  182.     void CmFileSend();
  183.     void CeFileSend(TCommandEnabler& ce);
  184.     void CmContextSelect();
  185.     void CeContextSelect(TCommandEnabler& ce);
  186.  
  187.   protected:
  188.     void SetupWindow();
  189.     void CleanupWindow();
  190.  
  191.     // Event handlers
  192.     //
  193.     void TvnSelChanged(TTwNotify far& notify);
  194.     void LvnGetDispInfo(TLwDispInfoNotify& dispInfo);
  195.     bool LvnBeginLabelEdit(TLwDispInfoNotify& dispInfo);
  196.     void LvnEndLabelEdit(TLwDispInfoNotify& dispInfo);
  197.  
  198.   private:
  199.     bool   AreFilesSelected();
  200.     void   AddDirectory(const char* dir, TTreeNode&);
  201.     string GetParentDirectory(TTreeNode&);
  202.  
  203.     // Data members
  204.     //
  205.     TPaneTreeWindow* TreeWind;
  206.     TPaneListWindow* ListWind;
  207.     TImageList*  Images;
  208.  
  209.   DECLARE_RESPONSE_TABLE(TClientWindow);
  210.   DECLARE_HELPCONTEXT(TClientWindow);
  211. };
  212.  
  213.  
  214. //
  215. // class TSpeedBallWindow
  216. // ~~~~~ ~~~~~~~~~~~~~~~~
  217. // Class to manage the bouncing ball using WinG.
  218. // Has context-sensitive menu.
  219. //
  220. class TSpeedBallWindow : public TWindow {
  221.   public:
  222.     // Constructors
  223.     //
  224.     TSpeedBallWindow(TWindow* parent);
  225.  
  226.     // Overides
  227.     //
  228.     void SetupWindow();
  229.     void CleanupWindow();
  230.     bool IdleAction(long);
  231.     void Paint(TDC&, bool, TRect&);
  232.  
  233.     // Event handlers
  234.     //
  235.     void EvSize(uint, TSize&);
  236.     void EvPaletteChanged(HWND hWndPalChg);
  237.     bool EvQueryNewPalette();
  238.  
  239.     // These data members are public to simplify usage.
  240.     // A real application would make these private with accessors.
  241.     //
  242.     uint32        Delay;
  243.     bool          EnableSound;
  244.     bool          BlitterBlocks;
  245.     TDiBitmap*    BallBitmap;
  246.  
  247.   private:
  248.     // Varibales for tracking speed ball position, limit and delta.
  249.     //
  250.     int XLimit;
  251.     int YLimit;
  252.     int XDelta;
  253.     int YDelta;
  254.     int XPosition;
  255.     int YPosition;
  256.  
  257.     // State variable for SpritBitBlt or CopyBitBlt.
  258.     //
  259.     TClientDC*      ClientDC;
  260.     TPalette*       Palette;
  261.     TDibDC*         BallDC;
  262.     TDibDC*         DisplayDC;
  263.     TDiBitmap*      DisplayBitmap;
  264.     TMciWaveAudio*  WaveAudio;
  265.  
  266.   DECLARE_RESPONSE_TABLE(TSpeedBallWindow);
  267. };
  268.  
  269. //
  270. // class TAboutWindow
  271. // ~~~~~ ~~~~~~~~~~~~
  272. // Manages the About window.
  273. // Has context-sensitive help.
  274. //
  275. class TAboutWindow : public TLayoutWindow {
  276.   public:
  277.     TAboutWindow(TWindow* parent);
  278.  
  279.     void SetupWindow();
  280.     void CleanupWindow();
  281.  
  282.     void CmOk();
  283.     void CmOptions();
  284.     void CmHelp();
  285.  
  286.     void EvGetMinMaxInfo(MINMAXINFO far& minmaxinfo);
  287.  
  288.   private:
  289.     TSpeedBallWindow* SpeedBall;
  290.     TButton*          Ok;
  291.     TButton*          Options;
  292.     TButton*          Help;
  293.  
  294.   DECLARE_RESPONSE_TABLE(TAboutWindow);
  295.   DECLARE_HELPCONTEXT(TAboutWindow);
  296. };
  297.  
  298. //
  299. // class TBlazerSplash
  300. // ~~~~~ ~~~~~~~~~~~~~
  301. class TBlazerSplash : public TSplashWindow {
  302.   public:
  303.     TBlazerSplash(TDib& dib,
  304.                   int width,
  305.                   int height,
  306.                   int style = None,
  307.                   uint timeOut = 0,       // in milliseconds
  308.                   const char far* title = 0,
  309.                   TModule* module = 0);
  310.    ~TBlazerSplash();
  311.     TMciWaveAudio* Engine;
  312. };
  313.  
  314.  
  315. //
  316. // Global declarations
  317. //
  318. extern TStatusBar*    StatusBar;
  319. extern TComboBox*     ListOfDrives;
  320. extern TBlazerApp*    Application;
  321. extern TClientWindow* ClientWindow;
  322.  
  323. #define HELPFILENAME "blazer.hlp"
  324. #define INIFILENAME  "blazer.ini"
  325.  
  326. //
  327. inline TMailer*
  328. TBlazerApp::GetMailer()
  329. {
  330.   return Mailer;
  331. }
  332.  
  333. #endif // BLAZER_H
  334.